package team.damo.admin.controller;

import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.damo.admin.model.User;
import team.damo.admin.service.UserService;
import team.damo.common.utils.ResponseEntity;

/**
 * @Author: ZhangHeng
 * @Description: TODO
 * @DateTime: 2024/3/12 10:35
 **/
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping(value = "/api/register")
    public ResponseEntity Register(@RequestBody User user){
        return userService.register(user);
    }
    @PostMapping(value = "/api/login")
    public ResponseEntity login(@RequestBody User user) {
        return userService.login(user);
    }
    @CrossOrigin
    @GetMapping(value = "/api/logout")
    @ResponseBody
    public ResponseEntity logout(){
        return ResponseEntity.ok();
    }

}
